package Leetcode;

public class Leetcode_168 {
    public static int minStartValue(int[] nums) {
        int accSum = 0, accSumMin = 0;
        for (int num : nums) {
            accSum += num;
            accSumMin = Math.min(accSumMin, accSum);
        }
        return -accSumMin + 1;
    }

    public static void main(String[] args) {
        int[] nums = {-3,2,-3,4,2};
        System.out.println(minStartValue(nums));
    }
}
